%code
const
cIndentString = ' '; // the trailing space is required for IE
var
AShowCounts: Boolean;
function StringRepeat(AString: WideString; ARepeat: Integer): WideString;
var
i: Integer;
begin
result := toWideString('');
for i := 1 to ARepeat do
result := result + AString;
end;
function DetermineScriptOnType (AType: Char): WideString;
begin
if AType = 'M' then
result := 'albumimages.psc'
else if AType = 'G' then
result := 'galleryimages.psc'
else if AType = 'C' then
result := 'collimages.psc';
end;
function FormatResult (AGUID: String; AName: WideString; ACount: Integer; AType: Char);
begin
result := toWideString('');
result := result + '';
if AShowCounts then
result := result + WideFormat ('%s [%d]', [AName, ACount])
else
result := result + AName;
result := result + '';
end;
var
AParentGUID: String;
ALevel: Integer;
AModels: TImageModelItems;
AModel: TImageModel;
AGalleries: TImageGalleries;
AGallery: TImageGallery;
AColls: TImageCollections;
AColl: TImageCollection;
ASubColls: TImageCollections;
ASubColl: TImageCollection;
i: Integer;
AExpand: Boolean;
begin
result := toWideString('');
AShowCounts := (Request.Params.Values['showCounts'] = 'y');
AParentGUID := Trim(Request.Params.Values['GUID']);
if AParentGUID = '' then
AParentGUID := 'top';
AExpand := Request.Params.Values['expand'] ='y';
if not IsValidNumberString(Request.Params.Values['level'], False) then
ALevel := 0
else
ALevel := StrToInt(Request.Params.Values['level']);
if AParentGUID = 'top' then
begin
AModels := TImageModelItems.Create (TImageModelItem, '');
Catalog.EnumModels (AModels, False, False, AShowCounts);
for i := 0 to AModels.Count - 1 do
begin
AModel := AModels.Items[i].Model;
result := result + '
';
result := result + '
' +
'
' +
' ' + FormatResult(AModel.GUID, AModel.ModelName, AModel.PhotoCount, 'M') +
'';
result := result + '
';
end;
AModels.Free;
end
else
begin
if ALevel = 1 then
begin
AModel := TImageModel.Create(nil);
Catalog.EnumModel (AParentGUID, AModel, AShowCounts);
if AExpand then
result := result + StringRepeat(cIndentString, ALevel - 1) +
'' +
'
' +
' ' +
FormatResult(AParentGUID, AModel.ModelName, AModel.PhotoCount, 'M') +
''
else
result := result + StringRepeat(cIndentString, ALevel - 1) +
'' +
'
' +
' ' +
FormatResult(AParentGUID, AModel.ModelName, AModel.PhotoCount, 'M') +
'';
if AExpand then
begin
AGalleries := TImageGalleries.Create(TImageGallery, '');
AGalleries.Clear;
Catalog.EnumModelGalleries (AModel, AGalleries, AShowCounts);
for i := 0 to AGalleries.Count - 1 do
begin
AGallery := AGalleries.Items[i];
result := result + '';
result := result + StringRepeat(cIndentString, ALevel) +
iif (not Catalog.GalleryHasCollections (AGallery.GUID),
'',
'
' +
'
' +
''
) +
' ' +
FormatResult(AGallery.GUID, AGallery.GalleryName, AGallery.PhotoCount, 'G') +
'';
result := result + '
';
end;
AGalleries.Free;
end;
AModel.Free;
end
else if ALevel = 2 then
begin
AGallery := TImageGallery.Create(nil);
AGallery.GUID := AParentGUID;
Catalog.EnumModelGallery (AGallery, AShowCounts);
if AExpand then
result := result + StringRepeat(cIndentString, ALevel - 1) +
iif (not Catalog.GalleryHasCollections (AGallery.GUID),
'',
'' +
'
' +
''
) +
' ' +
FormatResult(AParentGUID, AGallery.GalleryName, AGallery.PhotoCount, 'G') +
''
else
result := result + StringRepeat(cIndentString, ALevel - 1) +
iif (not Catalog.GalleryHasCollections (AGallery.GUID),
'',
'' +
'
' +
''
) +
' ' +
FormatResult(AParentGUID, AGallery.GalleryName, AGallery.PhotoCount, 'G') +
'';
if AExpand then
begin
AColls := TImageCollections.Create(TImageCollection, '');
Catalog.EnumGalleryCollections (AGallery, AColls, AShowCounts);
for i := 0 to AColls.Count - 1 do
begin
AColl := AColls.Items[i];
result := result + '';
result := result + StringRepeat(cIndentString, ALevel) +
iif (not Catalog.CollectionHasCollections (AColl.GUID),
'',
'
' +
'
' +
''
) +
' ' +
FormatResult(AColl.GUID, AColl.CollectionName, AColl.PhotoCount, 'C') +
'';
result := result + '
';
end;
AColls.Free;
end;
AGallery.Free;
end
else if ALevel >= 2 then
begin
AColl := TImageCollection.Create(nil);
AColl.GUID := AParentGUID;
Catalog.EnumModelCollection (AColl, AShowCounts);
if AExpand then
result := result + StringRepeat(cIndentString, ALevel - 1) +
iif (not Catalog.CollectionHasCollections (AColl.GUID),
'',
'' +
'
' +
''
) +
' ' +
FormatResult(AParentGUID, AColl.CollectionName, AColl.PhotoCount, 'C') +
''
else
result := result + StringRepeat(cIndentString, ALevel - 1) +
iif (not Catalog.CollectionHasCollections (AColl.GUID),
'',
'' +
'
' +
''
) +
' ' +
FormatResult(AParentGUID, AColl.CollectionName, AColl.PhotoCount, 'C') +
'';
if AExpand then
begin
ASubColls := TImageCollections.Create(TImageCollection, '');
Catalog.EnumCollectionCollections (AColl, ASubColls, AShowCounts);
for i := 0 to ASubColls.Count - 1 do
begin
ASubColl := ASubColls.Items[i];
result := result + '';
result := result + StringRepeat(cIndentString, ALevel) +
iif (not Catalog.CollectionHasCollections (ASubColl.GUID),
'',
'
' +
'
' +
''
) +
' ' +
FormatResult(ASubColl.GUID, ASubColl.CollectionName, ASubColl.PhotoCount, 'C') +
'';
result := result + '
';
end;
ASubColls.Free;
end;
AColl.Free;
end
end;
end;
%/code